<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0"/>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title>MCU MANAGER</title>
	<%@ include file="/WEB-INF/jsp/common/cssjs2.jsp" %>
	
	<script type="text/javascript">
		$(function(){
			$('.easyui-validatebox').validatebox();
			$('.easyui-validatebox[required]').after("<font color='red'> *</font>");
		});
		
		function doSubmit(){
			$('#id_form').form('submit', {
		        url:"<c:url value='/app/setup/network/address'/>",
		        onSubmit: function(){
		        	if($('.easyui-validatebox').validatebox("isValid")==false){
		        		return false;
		        	}else{
						return true;
					}
		        },
		        success:function(data){
					if("<fmt:message key="operation.success"/>" != data)
						alert(data);
					parent.closeWin();
		        }
			});
		}
		
		function reboot(){
			if(confirm("<fmt:message key='common.cofirm.reboot' />")){
				$.ajax({
					url:"<c:url value='/app/setup/reboot'/>",
					type:"GET",
					data:{
						times:new Date().valueOf()
					},
					success:function(data){
						alert("<fmt:message key='common.tip.afterReboot' />");
						parent.closeWin();
					}
				});
			}
		}
	</script>
	
	<style type="text/css">
	    html, body,form {
	        width: 100%;
	        height: 100%;
	        margin: 0px;
	        overflow: hidden;
	    }
	</style>
</head>
<body class="dialog">
<form id="id_form" method="post">
<input type="hidden" value="PUT" name="_method" />
<table border="0" style="width:100%;text-align:left;font-size:12px;margin:5px;" cellpadding="3" cellspacing="0">
	<thead>
		<tr>
			<th colspan="2">
				<fmt:message key="setup.network.address.header"/>
			</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td width="30%"><fmt:message key='setup.network.address.interface'/></td>
			<td width="70%">eth0</td>
		</tr>
		<tr>
			<td><fmt:message key='setup.network.address.ip'/></td>
			<td>
                <input type="text" name="if0ip" value="${model.if0ip}" class="easyui-validatebox" required="true" validtype="ip" disabled="disabled"  />
			<input type="hidden" name="if0mac" value="${model.if0mac}" />
			</td>
		</tr>
		<tr>
			<td><fmt:message key='setup.network.address.mask'/></td>
			<td><input type="text" name="if0mask" value="${model.if0mask}" class="easyui-validatebox" required="true" validtype="ip" disabled="disabled"  /></td>
		</tr>
		<tr>
			<td><fmt:message key='setup.network.address.gateway'/></td>
			<td><input type="text" name="if0gw" value="${model.if0gw}"  class="easyui-validatebox" validtype="ip" disabled="disabled" /></td>
		</tr>
		<c:if test="${model.hasif1==true}">
		<tr>
			<td><fmt:message key='setup.network.address.interface'/></td>
			<td>eth1</td>
		</tr>
		<tr>
			<td><fmt:message key='setup.network.address.ip'/></td>
			<td>
			<input type="text" name="if1ip" value="${model.if1ip}" class="easyui-validatebox" required="true" validtype="ip" disabled="disabled" />
			<input type="hidden" name="if1mac" value="${model.if1mac}"  />
			</td>
		</tr>
		<tr>
			<td><fmt:message key='setup.network.address.mask'/></td>
			<td><input type="text" name="if1mask" value="${model.if1mask}" class="easyui-validatebox" required="true" validtype="ip" disabled="disabled" /></td>
		</tr>
		<tr>
			<td><fmt:message key='setup.network.address.gateway'/></td>
			<td><input type="text" name="if1gw" value="${model.if1gw}" class="easyui-validatebox" validtype="ip" disabled="disabled" /></td>
		</tr>
		</c:if>
	</tbody>
</table>

<table border="0" style="width:100%;text-align:left;font-size:12px;margin:5px;" cellpadding="3" cellspacing="0">
	<thead>
		<tr>
			<th colspan="2">
				<fmt:message key="setup.network.dns.header"/>
			</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td width="30%"><fmt:message key='setup.network.dns.primary'/></td>
			<td width="70%"><input type="text" name="nameserver1" value="${model.nameserver1}" class="easyui-validatebox" validtype="ip" disabled="disabled" /></td>
		</tr>
		<tr>
			<td><fmt:message key='setup.network.dns.secondary'/></td>
			<td><input type="text" name="nameserver2" value="${model.nameserver2}" class="easyui-validatebox" validtype="ip" disabled="disabled" /></td>
		</tr>
		<%--
        <tr>
            <td colspan="2" align="center">
                <p></p>
                <input type="button" onclick="doSubmit();" class="mybtn" value="<fmt:message key='btn.ok'/>">
            </td>
        </tr>
        <tr>
			<td colspan="2">
				<p style="color:red;">
				<fmt:message key="common.tip" /> : <fmt:message key="common.tip.reboot" />
				</p>
				<p>
                <input type="button" onclick="doSubmit();" class="mybtn" value="<fmt:message key='btn.ok'/>">
				<button onclick="reboot();" class="mybtn"><fmt:message key='btn.reboot'/></button>
				<button onclick="parent.closeWin();" class="mybtn"><fmt:message key='btn.cancel'/></button>
				</p>
			</td>
		</tr>
        --%>
	</tbody>
</table>
</form>
</body>
</html>